﻿Imports IntoNails.ViewModel

Class Application

    Private viewModel As MainWindowViewModel
    Private window As MainWindow

    Private Const USER_PROFILES As String = "{0}\Data\Users.dat"

    ' Application-level events, such as Startup, Exit, and DispatcherUnhandledException
    ' can be handled in this file.
    Protected Overrides Sub OnStartup(ByVal e As System.Windows.StartupEventArgs)
        MyBase.OnStartup(e)

        window = New MainWindow()
        viewModel = New MainWindowViewModel(String.Format(USER_PROFILES, Environment.CurrentDirectory))

        AddHandler viewModel.RequestClose, AddressOf RemoveRequestCloseHandler

        window.DataContext = viewModel
        window.Show()
    End Sub

    Private Sub RemoveRequestCloseHandler(ByVal sender As Object, ByVal e As EventArgs)
        RemoveHandler viewModel.RequestClose, AddressOf RemoveRequestCloseHandler
        window.Close()
    End Sub

End Class
